package cn.com.yusys.yusp.admin.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SessionRequestConfig implements WebMvcConfigurer {
    @Bean
    public  SessionRequestInterceptor getSessionRequestInterceptor(){
        return new SessionRequestInterceptor();
    }
    /*
    此方法用于注册拦截器，我们自己写好的拦截器需要通过这里添加注册才能生效
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册SessionRequestInterceptor拦截器
        InterceptorRegistration registration = registry.addInterceptor(getSessionRequestInterceptor());
        registration.addPathPatterns("/**");//所有路径都被拦截
        registration.excludePathPatterns(
                "/","/esb","/api-doc","/v2/api-docs","/actuator/**","/oauth/token","/api/codeImage/**","/api/adminsmlogicsys/logicsyskv","/api/server","/error",
                "/echain/studio/eChainStudio.jar","/definitionservlet","/echain/studio/studio.properties","/swagger-resources/**","/swagger-resources",
                "/api/session/info","/api/account/menuandcontr","/actuatorApp","/api/sznshauth/checktoken","/sso.do","/ssomslogin.do"
        );
        registration.excludePathPatterns(
                "/**/*.js","/**/*.css","/**/*.html","/**/*.ttf","/**/*.woff","/**/*.svg","/**/*.eot","/**/*.png","/**/*.gif",
                "/**/*.ico","/**/*.json"
        );
    }

}
